/*
防抖
*/
export function debounce(callback, t = 300) {
  let time = null;
  return function() {
    clearTimeout(time);
    time = setTimeout(() => {
      callback && callback.call(this, ...arguments);
    }, t);
  };
}

/*
节流
*/
export function throttle(callback, t = 300) {
  let startTime = 0;
  return function() {
    let endTime = +new Date();
    if (endTime - startTime >= t) {
      callback && callback.call(this, ...arguments);
      startTime = endTime;
    }
  };
}
